package com.bs.medicine.utils;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

public class DetailLogger extends Logger{

	private static DetailLoggerFactory detailLoggerFactory = new DetailLoggerFactory();
	
	static String FQCN = (new StringBuilder(String.valueOf(com.bs.medicine.utils.DetailLogger.class.getName()))).append(".").toString();
	
	protected DetailLogger(String name) {
		super(name);
	}

	public static DetailLogger getDetailLogger(Class clazz){
		return (DetailLogger) Logger.getLogger(clazz.getName(), detailLoggerFactory);
	}
	
	public static DetailLogger getDetailLogger(String name){
		return (DetailLogger) Logger.getLogger(name,detailLoggerFactory);
	}
	
	public static DetailLogger getDetailLogger(String name,DetailLoggerFactory detailLoggerFactory){
		return (DetailLogger) Logger.getLogger(name,detailLoggerFactory);
	}
	
	public void debug(int sequenceId, String description) {
		if (isDebugEnabled())
			super.log(FQCN, Level.DEBUG, (new StringBuilder("[sequenceId:"))
					.append(sequenceId).append("]").append("[description:")
					.append(description).append("]").toString(), null);
	}

	public void debug(int sequenceId, String description, Exception exception) {
		if (isDebugEnabled())
			super.log(FQCN, Level.DEBUG, (new StringBuilder("[sequenceId:"))
					.append(sequenceId).append("]").append("[description:")
					.append(description).append("]").append("[").append(
							exception).append("]").toString(), null);
	}

	public void info(int sequenceId, String description) {
		if (isInfoEnabled())
			super.log(FQCN, Level.INFO, (new StringBuilder("[sequenceId:"))
					.append(sequenceId).append("]").append("[description:")
					.append(description).append("]").toString(), null);
	}

	public void info(int sequenceId, String description, Exception exception) {
		if (isInfoEnabled())
			super.log(FQCN, Level.INFO, (new StringBuilder("[sequenceId:"))
					.append(sequenceId).append("]").append("[description:")
					.append(description).append("]").append("[").append(
							exception).append("]").toString(), null);
	}

	public void error(int sequenceId, String description, Exception exception) {
		super.log(FQCN, Level.ERROR, (new StringBuilder("[sequenceId:"))
				.append(sequenceId).append("]").append("[description:").append(
						description).append("]").append("[").append(exception)
				.append("]").toString(), null);
	}

	public void warn(int sequenceId, String description) {
		super.log(FQCN, Level.WARN, (new StringBuilder("[sequenceId:")).append(
				sequenceId).append("]").append("[description:").append(
				description).append("]").toString(), null);
	}

	public void warn(int sequenceId, String description, Exception exception) {
		super.log(FQCN, Level.WARN, (new StringBuilder("[sequenceId:")).append(
				sequenceId).append("]").append("[description:").append(
				description).append("]").append("[").append(exception).append(
				"]").toString(), null);
	}
}
